//
//  HNNewsViewController.m
//  JHFBaseProject
//
//  Created by 朱传正 on 2016/12/13.
//  Copyright © 2016年 好牛. All rights reserved.
//

#import "HNNewsViewController.h"
#import "HNNewCell.h"
#import "HNGetMegTableViewController.h"
#import "ConversationListController.h"

@interface HNNewsViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong)UITableView *tableView;

@property (nonatomic,strong)NSArray *dataSource;

@end

@implementation HNNewsViewController


- (void)viewDidLoad {
    [super viewDidLoad];
  
}


-(void)drawView{
    self.title = @"消息";
    NSArray *imageStr = [NSArray arrayWithObjects:@"系统.png",@"图层-2.png",@"doctorConsult.png", nil];
    NSArray *titleStr = [NSArray arrayWithObjects:@"系统消息",@"订单消息",@"名医咨询", nil];
    NSArray *detailStr = [NSArray arrayWithObjects:@"系统推送消息",@"获取商品配送信息",@"连线名医回复信息", nil];
    
    NSMutableArray *dataSource = [[NSMutableArray alloc]init];
    for (int i = 0; i<imageStr.count; i++) {
        NSDictionary *cellDic = [NSDictionary dictionaryWithObjectsAndKeys:imageStr[i],@"imageStr",titleStr[i],@"titleStr",detailStr[i],@"detailStr", nil];
        [dataSource addObject:cellDic];
    }
    
    _dataSource = dataSource;
    
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreen_Width, kScreen_Height-114)];
    [_tableView setBackgroundColor:RGB(236, 240, 241)];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.bounces = NO;
    [_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [self.view addSubview:_tableView];
    
}

#pragma -mark TableView
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [_dataSource count];
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 70;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellIdentifier = @"HNNewCell";
 
        HNNewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil]firstObject];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.cellImage.image = [UIImage imageNamed:[_dataSource[indexPath.row] objectForKey:@"imageStr"]];
    cell.cellTitle.text = [_dataSource[indexPath.row] objectForKey:@"titleStr"];
    cell.celldetailMsg.text = [_dataSource[indexPath.row] objectForKey:@"detailStr"];
    
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 2) {
        ConversationListController *VC = [[ConversationListController alloc]init];
        VC.title = @"名医咨询";
        [self.navigationController pushViewController:VC animated:YES];
    }else{
        HNGetMegTableViewController *getMegVc = [[HNGetMegTableViewController alloc]init];
        
        getMegVc.typeIndex = indexPath.row;
        
        NSLog(@"indexPath.row = %ld",indexPath.row);
        
        [self.navigationController pushViewController:getMegVc animated:YES];
    }
  
}




@end
